<template>
	<view class="wraptop">

		<view class="content_input">
			<input type="text" value="" v-model="userinfo.synopsis" class="input_cot" style="text-align: left;border-radius: 40px;background-color: rgb(250,250,250);"
			 placeholder="个人简介" />
		</view>
		<view class="btn" @click="regup">
			<text>完成</text>
		</view>
		<!-- 		<view class="bottom_cont">
			<text>《使用条款和隐私政策》</text>
			<text @click="gologin">已经有账户了！ 登陆</text>
		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				countdown: 60,
				btnDisabled: false,
				text: '获取验证码',
				view_class: {
					height: ""
				},
				userinfo: {
					name: '',
					img:'',
					synopsis:''
				}
			}
		},
		onLoad: function() {
			this.view_class.height = uni.getSystemInfoSync().windowHeight
			console.log(this.view_class.height)
			let token = uni.getStorageSync("token")
			uni.request({
			    url: this.G_base+'/api/userinfo',
				method:"GET",
			    header: {
			        'content-type':'application/x-www-form-urlencoded' ,
					'Authori-zation': 'Bearer ' + token
			    },
			    success: (res) => {
			        console.log(res);
					this.userinfo.img = res.data.data.data.avatar
					this.userinfo.name =res.data.data.data.nickname
					this.userinfo.synopsis =res.data.data.data.synopsis
			        
			    },
				fail: (err) => {
					console.log(err)
				}
			});
		},
		methods: {
			regup() {
				let token = uni.getStorageSync("token")
				uni.request({
					url: this.G_base + '/api/user/edit',
					data: {
						avatar: this.userinfo.img,
						nickname: this.userinfo.name,
						synopsis:this.userinfo.synopsis
					},
					method: "POST",
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'Authori-zation': 'Bearer ' + token
					},
					success: (res) => {
						console.log(res);
						if(res.data.status==200){
							uni.showToast({
								title:"修改成功"
							})
							setTimeout(()=>{
								uni.navigateBack({
									delta:1
								})
							},1000)
						}
						


					},
					fail: (err) => {
						console.log(err)
					}
				});
			},
		}
	}
</script>

<style scoped>
	.bottom_cont text:nth-child(1) {
		margin-bottom: 7px;
	}

	.bottom_cont text {

		top: 660px;
		width: 154px;
		color: rgba(16, 16, 16, 1);
		font-size: 14px;
		font-family: PingFangSC-regular;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-left: 50%;
		transform: translateX(-50%);
	}

	.wraptop {
		background-color: rgb(255, 255, 255);
		padding-bottom: 30%;
	}

	.content_input {
		display: flex;
		justify-content: center;
		align-items: center;
		flex-wrap: wrap;
		margin-top: 50px;
	}

	.input_cot {
		padding-left: 12px;
		width: 300px;
		height: 54px;
		line-height: 54px;
		border-radius: 20px;
		text-align: center;
		margin-bottom: 22px;
		color: rgba(16, 16, 16, 1);
		font-size: 14px;
		font-family: PingFangSC-regular;
	}

	.bottom_cont {
		margin-top: 32px;
	}

	.btn {

		background: -webkit-linear-gradient(left, #a00000, #e10004, #a00000);
		left: 107px;
		top: 578px;
		width: 164px;
		height: 50px;
		line-height: 20px;
		border-radius: 40px;
		text-align: center;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-left: 50%;
		transform: translateX(-50%);

	}

	.btn text {
		color: #FFFFFF;
		left: 189px;
		top: 593px;
		width: 40px;
		height: 20px;
		font-size: 20px;
		text-align: center;
		font-family: PingFangSC-regular;
	}
</style>